import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.LinkedList;

public class Main {
	public static int[] getNdata(String input) {
		String[] spInput = input.split(" ");
		int k = spInput.length;
		int[] nData = new int[k];
		
		for(--k; k >= 0; k--)
			nData[k] = Integer.parseInt(spInput[k]);
		return nData;
	}
	public static int getBiggestM(int n) {
		LinkedList<Integer> reservoir = new LinkedList<Integer>();
		
		for(int i = 1; i <= n; i++)
			reservoir.add(i);

		int m = n - 1;
		for( ; m > 0; m--) {
			LinkedList<Integer> tmp = new LinkedList<Integer>(reservoir);

			while(tmp.size() != 1) {
				for(int i = 1; i < m; i++)
					tmp.addLast(tmp.removeFirst());

				if(tmp.peek() == n)
					break;
				else
					tmp.removeFirst();
			}

			if(tmp.size() == 1 && tmp.peek() == n)
				break;
		}
		return m;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output;
		String input;
		int k;
		int[] nData;
		
		while((input = br.readLine()) != null) {
			k = Integer.parseInt(input);
			input = br.readLine();
			nData = getNdata(input);
			
			output = new StringBuilder();
			
			for(k = 0; k < nData.length; k++)
				output.append(getBiggestM(nData[k]) + "\n");
			
			System.out.print(output);
		}
	}
}